package cn.zzf.core;

import cn.zzf.po.ClassroomInfo;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author GaoFeng2017
 * @date 2018-02-23 12:08:26
 **/

public class ClassroomHandler implements ContentHandler{

    private List<String> items = new ArrayList<>(16);

    @Override
    public void handle(String content, String tid) {
        Pattern pattern = Pattern.compile("<option value=([^<>]{2,15})>[^<>]+</option>");
        Matcher matcher = pattern.matcher(content);
        while (matcher.find()) {
            ClassroomInfo classroomInfo = new ClassroomInfo();
            String item = matcher.group().replaceAll(".+>(.+)<.+","$1").trim();
            items.add(item);
        }

    }

    public List<String> getItems() {
        return items;
    }

    @Deprecated
    @Override
    public Map<String, String> parseContent(String content) {
        return null;
    }
}
